# load packages
library(dplyr)
library(waffle)
library(rworldmap)
library(tidyverse)
library(tidytext)
library(wordcloud)
library(ggplot2)
library(gridExtra)
This notebook was prepared with the following environmental settings.
print(R.version)
## _
## platform x86_64-apple-darwin15.6.0
## arch x86_64
## os darwin15.6.0
## system x86_64, darwin15.6.0
## status
## major 3
## minor 4.1
## year 2017
## month 06
## day 30
## svn rev 72865
## language R
## version.string R version 3.4.1 (2017-06-30)
## nickname Single Candle
In this project, I combined the demographic data from https://raw.githubusercontent.com/rit-public/HappyDB/master/happydb/data/demographic.csv and the cleaned processed happy moments text data <“processed_moments.csv”> generated by Tex_Processing.rmd together for the following analysis.
# Load Data
demoURL <- 'https://raw.githubusercontent.com/rit-public/HappyDB/master/happydb/data/demographic.csv'
demoData <- read.csv(demoURL)
hm_data <- read.csv("../output/processed_moments.csv")
pro_moments_demo <- merge(demoData, hm_data, by = c('wid')) ## Merge two dataframe by workder id
pro_moments_demo$age <- as.numeric(gsub("[A-Za-zčá]", ## Clean the age variable
"",as.character(pro_moments_demo$age)))
head(pro_moments_demo)
Question 1 to think before we go:
Top 3 Happy Moments Categories in past 24 Hours are: affection (32.9%),achievement (30.9%),enjoy_the_moment (13.3%).
Top 3 Happy Moments Categories in past 3 Months are: achievement (36.6%),affection (35.2%),bonding (10.9%).
In the past 24 hours/3 months, most people are happy for moments related to achievement, affection, enjoy_the_moment, and bonding.
As the reflection period gets longer, the percentage of small/daily moments, such as enjoy_the_moment, exercise, leisure and nature, decline overall; but the big/unsual moments, such as achievement, affection, and bonding, increases.
This actually makes sense. Since when reflection period gets shorter, a small moment that makes people happy could be much more impressive than longer reflection period; whereas the the reflection period gets longer, big moments related to achievement, affection or bondings could be much more impressive and memorable.
sort(table(pro_moments_demo$country), decreasing = TRUE)
##
## USA IND VEN CAN GBR PHL MEX VNM BRA AUS MKD
## 78941 16713 588 555 364 279 203 150 125 123 117 104
## SRB IDN THA DEU PRT NGA BGD BGR JAM EGY DNK DOM
## 96 90 90 84 84 81 69 67 60 57 51 51
## FRA TUR ALB ROU GRC LTU URY PAK ARE ITA MDA NZL
## 51 51 48 46 42 42 42 39 36 36 36 36
## PER KEN COL IRL PRI RUS TTO SWE SGP ESP FIN ZAF
## 34 33 32 30 30 30 30 27 24 23 21 21
## KWT MAC UGA AUT ARM JPN MYS NIC NLD POL UMI ASM
## 18 18 18 17 15 15 15 15 15 15 15 13
## BEL DZA LKA AFG ISL KNA MLT TWN ARG BRB CHL CZE
## 12 12 12 11 9 9 9 9 6 6 6 6
## EST GMB GTM HRV KOR MAR NPL SVN TCA BHS CRI CYP
## 6 6 6 6 6 6 6 6 6 3 3 3
## ECU ETH GHA HKG IRQ ISR KAZ LVA MUS NOR SAU SLV
## 3 3 3 3 3 3 3 3 3 3 3 3
## SUR TUN UKR VIR ZMB
## 3 3 3 3 3
Question 2 to think:
Do happy moments vary across countries?
If so, what does the pattern show?
Here, I visualized the top1 and top2 happy moments categories on the world map to help us get a general sense of this question (Keep in Mind: this could be much better if we were able to have more balanced sample).
Most of countries in North & South America Continents (USA, Cananda, Brazil, Columbia,etc) and Western Europe (UK, France, etc.) have top1 happy moments belonging to achievement, and top2 happy moments with affection.
In most Asia countries, people are more often happy for their affection and achievement.
For countries in Middle East and Africa, people are often happy for various moments. However, compaired with other countries, categories like affection and bonding could play a much more important role in Middle East and Africa.
Russia and Australia are kind of special but much similar in what makes their people happy, since the top1 and top2 happy moments categories in Russia are enjoy_the_moment & achievement; whereas in Australia, achievement & enjoy_the_moment are the top1 and top2 categories.
Below, I plotted the top 10 most frequent words used to express happy moments under 7 different categories:
Also, the most frequent 60 words through wordclouds as following:
achievement: doing well with job/exam/school/game/project, bought a car/house, got raise/bonus/money/promotions etc.
affection: had a great time with family members/boy or girl friends, etc.
bonding: had a great time with friends
enjoy_the_moment/ exercise/ leisure: had a great time with oneself, such as ate something nice/relax/workout/read books/watch movies and etc.
nature: walked in the nature, saw a nice view, etc
A few questions to think:
Whether some people are more likely to be happy for achievement?
while, whether some are more likely to be happy for having a great time with family/friends (affection & bonding)?
or, others are more likely to be happy for having a great time with his or her self (enjoy_the_moment, exercise, leisure, nature)?
people with no parenthood are more likely to recall happy moments with words from bonding,enjoy_the_moment,leisure, achievement.
however, people with parenthood are more likely to recall happy moments with words from affection.
Also, there seems to be no much difference in the components of happy moments across marital status, since all three types of genders are composed of affections, bonding, achievement, etc.
However, this does not mean marital status is not significant with other status combined, such as gender, parenthood, etc. Further investigation may be needed.
There are two slightly obvious trends in gender:
For people with age under 35, they are more likely to be happy about personal bondings, affections, and enjoy_the_moments.
But for age above 35, most of the happy moments coming from family, which belongs to affection.
When reflection period of recalling happy moments decreases, daily moments that make people happy could be much more impressive than those recalled with longer reflection period; however, as the the reflection period goes longer, unusual moments related to achievement, affection or bondings could be much more impressive and memorable.
The most commom happy moment in somehow varies across different contries of residence. The pattern itself has some rule across different continents as well. Even though the happy moments in this dataset are not evenly distributed across countries, it is still valuable for us to think. And, maybe we could further investigated this part, if more balanced dataset is available.
Although the details of happy moments are quite diverse, there are still much similarities when comes to specific situations. For example, people are happy b/c:
achievement: did well with job/exam/school/game/project, bought a car/house, got raise/bonus/money/promotions etc.
affection: had a great time with family members/boy or girl friends.
bonding: had a great time/dinner/fun with friends.
enjoy_the_moment/ exercise/ leisure: had a great time with oneself, such as ate something nice/relax/workout/read books/watch movies and etc.
nature: walked in the nature, saw a nice view, etc